{include file="public/header"}

<body>
    <div class="layui-fluid">
        <div class="layui-row">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">管理员账号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="username" name="username" value="{$admin.username}" required=""
                                lay-verify="required" autocomplete="off" class="layui-input" readonly disabled>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">管理员备注</label>
                        <div class="layui-input-inline">
                            <input type="text" id="name" name="nickname" value="{$admin.nickname|default=''}"
                                required="" lay-verify="required" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">更改密码</label>
                        <div class="layui-input-inline">
                            <input type="text" id="password" name="password" value="" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">确认密码</label>
                        <div class="layui-input-inline">
                            <input type="text" id="passworder" name="passworder" value="" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit="" lay-filter="add">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    {include file="public/footer"}
    <script>
        layui.use(['form', 'layer'], function () {
            $ = layui.jquery;
            var form = layui.form
                , layer = layui.layer;
            //监听提交
            form.on('submit(add)', function (data) {
                //发异步，把数据提交给php
                if (data.field.password != data.field.passworder) {
                    layer.msg('密码不一致', { icon: 2, time: 1000 });
                }
                $.ajax({
                    'type': 'post',
                    data: data.field,
                    success: function (res) {
                        console.log(res);
                        if (res.code == 0) {
                            layer.msg(res.msg, { icon: 6, time: 1000 }, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.location.reload();
                                parent.layer.close(index);
                            });
                        } else {
                            layer.msg(res.msg, { icon: 2, time: 1000 });
                        }
                    }
                });
                return false;
            });
        });
    </script>